#pragma once

class CLock
{
public:
	CLock(void){ 
		           InitializeCriticalSection(&m_cs) ;
				 
				}; 
	
	virtual ~CLock(void){  
		           
		            DeleteCriticalSection(&m_cs);
	             }; 
	void Lock()
	{
        EnterCriticalSection(&m_cs);
	}
    
	void UnLock()
	{
        LeaveCriticalSection(&m_cs); 
	}


private: 
	  CRITICAL_SECTION  m_cs;
};

class CGuard : public CLock 
{
public:
  
	   CGuard ()
	  {
		  Lock() ;
	  }

	virtual  ~CGuard()
	  {
		 UnLock() ;
	  }

};